﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Copy4Backup
{
	public class FileChangedEventArgs : EventArgs
	{
		#region Fields

		#endregion Fields

		#region Properties

		/// <summary>
		/// Gets the file information data.
		/// </summary>
		public FileInfo FileInfoData
		{
			get;
			private set;
		}

		/// <summary>
		/// Gets or sets the Disk instance.
		/// </summary>
		public Disk Disk
		{
			get;
			set;
		}

		#endregion Properties

		#region Methods

		/// <summary>
		/// Prevents the default ctor usage.
		/// </summary>
		private FileChangedEventArgs()
		{
		}

		/// <summary>
		/// Creates and initializes the instance.
		/// </summary>
		/// <param name="fileName">The file name.</param>
		/// <param name="disk">The Disk instance.</param>
		public FileChangedEventArgs(FileInfo fileInfo, Disk disk)
		{
			FileInfoData = fileInfo;
			Disk = disk;
		}

		#region EventArgs overrided methods

		/// <summary>
		/// Compares the instance with an object.
		/// </summary>
		/// <param name="obj">An object to compare</param>
		/// <returns>True, if an object ihas type StateChangedEventArgs and all properties are equal.</returns>
		public override bool Equals(object obj)
		{
			bool isEqual = (null != obj);

			if (isEqual)
			{
				isEqual = (obj.GetType() == this.GetType());
			}

			if (isEqual)
			{
				isEqual = (this.FileInfoData.Equals(((obj) as FileChangedEventArgs).FileInfoData));
			}

			return base.Equals(obj);
		}

		/// <summary>
		/// Gets hash code (ToString - hash code).
		/// </summary>
		/// <returns>The hash code (ToString - hash code).</returns>
		public override int GetHashCode()
		{
			return ToString().GetHashCode();
		}

		/// <summary>
		/// Gets the text representation.
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			StringBuilder sb = new StringBuilder("FileChangedEventArgs");
			sb.AppendFormat(": FileInfoData: {0}", FileInfoData.ToString());
			
			return sb.ToString();
		}
		#endregion EventArgs overrided methods

		#endregion Methods
	}
}
